//k1 edit 21.12.09

private ["_center","_rotation","_obj","_pos","_parkedVehicleClasses"];

_center               = [_this, 0] call bis_fnc_param;
_rotation             = [_this, 1] call bis_fnc_param;
_staticWeaponClasses  = [_this, 2, []] call bis_fnc_param;
_parkedVehicleClasses = [_this, 3, []] call bis_fnc_param;
_parkedArmorClasses   = [_this, 4, []] call bis_fnc_param;
_staticAAClasses      = [_this, 5, []] call bis_fnc_param;

if (isNil "A3E_MotorPoolMarkerNumber") then {
    A3E_MotorPoolMarkerNumber = 0;
} else {
    A3E_MotorPoolMarkerNumber = A3E_MotorPoolMarkerNumber + 1;
};
_mNumber = A3E_MotorPoolMarkerNumber;

_fnc_createObject = {
    params["_className","_centerPos","_relativePos","_rotateDir","_relativeDir"];
    private["_object", "_realPos", "_realDir"];

    _fnc_rotatePos = {
        private ["_centerPos", "_pos", "_dir"];
        private ["_px", "_py", "_mpx", "_mpy", "_ma", "_rpx", "_rpy"];
        _centerPos = _this select 0;
        _pos = _this select 1;
        _dir = _this select 2;
        _px = _pos select 0;
        _py = _pos select 1;
        _mpx = _centerPos select 0;
        _mpy = _centerPos select 1;
        _ma = _dir;
        _rpx = ( (_px - _mpx) * cos(_ma) ) + ( (_py - _mpy) * sin(_ma) ) + _mpx;
        _rpy = (-(_px - _mpx) * sin(_ma) ) + ( (_py - _mpy) * cos(_ma) ) + _mpy;
        [_rpx, _rpy, (_pos select 2)];
    };

    _realPos = ([_centerPos, [(_centerPos select 0) + (_relativePos select 0), (_centerPos select 1) + (_relativePos select 1),(_relativePos select 2)], _rotateDir] call _fnc_rotatePos);
    _object = createVehicle [_className, _realPos, [], 0, "CAN_COLLIDE"];
    _object setdir (_relativeDir + _rotateDir);
    _object setPosATL _realPos;
    _object
};

_obj = objNull;
_obj = ["Land_HBarrier_3_F",_center,[-3.25,-15.625,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_3_F",_center,[3.875,-15.625,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-13,-9.5,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-5.25,-13.125,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-10.875,-13.125,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[6,-13.125,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-13,13,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-13,-3.875,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[0.25,16.625,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-13,1.75,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-11,16.625,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-13,7.375,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[5.875,16.625,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[-5.375,16.625,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[13.5,-9.5,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[11.625,-13.125,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[13.5,13,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[13.5,1.75,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[13.5,-3.875,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[13.5,7.375,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_HBarrier_5_F",_center,[11.5,16.625,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[-17.5,-9.625,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[-17.5,0.375,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[-7.125,19.875,0],_rotation,180] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[2.875,19.875,0],_rotation,180] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[-17.5,10.375,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[17.375,-10,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[17.375,0,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[17.375,10,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_10m_F",_center,[12.875,19.875,0],_rotation,180] call _fnc_createObject;
_obj = ["Land_New_WiredFence_5m_F",_center,[-14.625,19.875,0],_rotation,180] call _fnc_createObject;
_obj = ["Land_New_WiredFence_5m_F",_center,[-17.5,17.875,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_New_WiredFence_5m_F",_center,[17.375,17.5,0],_rotation,270] call _fnc_createObject;
_obj = ["Land_BagBunker_Small_F",_center,[-8.5,-18.125,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_BarGate_F",_center,[0.125,-18.125,0],_rotation,180] call _fnc_createObject;
_obj = ["Land_Cargo_Patrol_V1_F",_center,[9.375,-9,0],_rotation,0] call _fnc_createObject;
_obj = ["Land_Cargo_HQ_V1_F",_center,[6,7,0],_rotation,270] call _fnc_createObject;

_obj = ["Box_East_Ammo_F",_center,[0.5,11.75,1],_rotation,0] call _fnc_createObject;
_obj allowDamage false;
_obj = ["Box_NATO_AmmoOrd_F",_center,[11.25,-3.75,0],_rotation,180] call _fnc_createObject;
_obj allowDamage false;
_obj = ["Box_NATO_WpsLaunch_F",_center,[11.5,-1.257,0],_rotation,90] call _fnc_createObject;
_obj allowDamage false;

//Statics
_MGGMH = a3e_arr_Escape_SWC_MG_H + a3e_arr_Escape_SWC_GM_H;
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[10.696,-10.147,4.331],_rotation,135] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[-8.625,-18.5,-0.012],_rotation,180] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[3.25,4.25,3.11],_rotation,225] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[0.865,12.886,3.086],_rotation,315] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[10.73,6.414,3.11],_rotation,90] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _MGGMH;
_obj = [_gun,_center,[7.875,14.1,3.11],_rotation,0] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];

_SWEP = a3e_arr_Escape_SWC_MG + a3e_arr_Escape_SWC_MG_A;
_gun = selectRandom _SWEP;
_obj = [_gun,_center,[10.805,-10.42,0.1],_rotation,270] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_gun = selectRandom _SWEP;
_obj = [_gun,_center,[-3.357,14.0225,0.1],_rotation,180] call _fnc_createObject;
Escape_allStatics pushback _obj;
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];

if (productVersion select 2 < 200) then [{
	_box = ["Box_NATO_AmmoVeh_F",_center,[-8.16,10.42,0],_rotation,270] call _fnc_createObject;
	_box allowDamage false;
	clearWeaponCargoGlobal _box;
	clearMagazineCargoGlobal _box;
	clearItemCargoGlobal _box;
	clearBackpackCargoGlobal _box;
	_weapons = [];
	_weaponMagazines = [];
	_c = count a3e_arr_AmmoDepotVehicle - 1;
	for "_i" from 0 to _c do {
		private ["_handGunItem", "_weaponClassName", "_probabilityOfPrecence", "_minCount", "_maxCount", "_magazines", "_magazinesPerWeapon"];
        _handGunItem = a3e_arr_AmmoDepotVehicle select _i;
        _weaponClassName = _handGunItem select 0;
        _probabilityOfPrecence = _handGunItem select 1;
        _minCount = _handGunItem select 2;
        _maxCount = _handGunItem select 3;
        _magazines = _handGunItem select 4;
        _magazinesPerWeapon = _handGunItem select 5;
        if (random 100 <= _probabilityOfPrecence) then {
            _weaponCount = floor (_minCount + random (_maxCount - _minCount));
            _weapons pushBack [_weaponClassName, _weaponCount];
			_c = count _magazines - 1;
            for "_j" from 0 to _c do {
                _weaponMagazines pushBack [_magazines select _j, _weaponCount * _magazinesPerWeapon];
            };
        };
    };
	_items = [];
	_c = count a3e_arr_AmmoDepotVehicleItems - 1;
	for "_i" from 0 to _c do {
		private ["_item", "_itemClassName", "_probabilityOfPrecence", "_minCount", "_maxCount"];
		_item = a3e_arr_AmmoDepotVehicleItems select _i;
        _itemClassName = _item select 0;
        _probabilityOfPrecence = _item select 1;
        _minCount = _item select 2;
        _maxCount = _item select 3;
        if (random 100 <= _probabilityOfPrecence) then {
            _itemCount = floor (_minCount + random (_maxCount - _minCount));
            _items pushback [_itemClassName, _itemCount];
        };
    };
	if (count _weapons > 0 || {count _weaponMagazines > 0} || {count _items > 0}) then {
		{_box addWeaponCargoGlobal _x} forEach _weapons; 
		{_box addMagazineCargoGlobal _x} forEach _weaponMagazines;
		{_box addBackpackCargoGlobal [_x,4]} forEach a3e_arr_AmmoDepotVehicleBackpacks;
		{_box addItemCargoGlobal _x} forEach _items;
	};
},{
	_obj = ["Land_RepairDepot_01_green_F",_center,[-8.16,10.42,0],_rotation,270] call _fnc_createObject;
}];

//veh
_vehicle = selectRandom a3e_arr_ComCenDefence_heavyArmorClasses; //
_obj = [_vehicle,_center,[-6.42,-0.6,0],_rotation,90] call _fnc_createObject;
_obj setfuel (random 1);
_obj setDamage (random [0,.2,.5]);
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];
_parkedVehicleClasses append ["C_Heli_Light_01_civil_F","B_Heli_Light_01_F","I_Heli_light_03_unarmed_F"];
_vehicle = selectRandom _parkedVehicleClasses;
_obj = [_vehicle,_center,[-7.165,-7.1,0],_rotation,90] call _fnc_createObject;
_obj setfuel (random 1);
_obj setDamage (random [0,.2,.5]);
Escape_all_assets pushback _obj;
_obj setVariable ["Escape_assets_control", true, true];

Escape_campType_arr pushback [_center,"载具点","Jade"];
publicVariable "Escape_campType_arr";

["A3E_MotorPoolMapMarker" + str _mNumber,_center,"o_service"] call A3E_fnc_createLocationMarker;

_marker = createMarkerLocal ["A3E_MotorPoolPatrolMarker" + str _mNumber, _center];
_marker setMarkerShapeLocal "RECTANGLE";
_marker setMarkerAlphaLocal 0;
_marker setMarkerSizeLocal [40,38];


